#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
using namespace std;
vector<int> arr;
void ShellSort(vector<int> &arr)
{
    int n = arr.size();
    int d, i, j;
    for (d = n / 2; d >= 1; d /= 2)
        for (i = d + 1; i < n; ++i)
            if (arr[i] < arr[i - d])
            {
                arr[0] = arr[i];
                for (j = i - d; j > 0 && arr[0] < arr[j]; j -= d)
                    arr[j + d] = arr[j];
                arr[j + d] = arr[0];
            }
}
int main()
{
    arr = {0, 4, 5, 2, 3, 1, 23, 4};
    ShellSort(arr);
    for (int i = 1; i < arr.size(); ++i)
    {
        printf(" %d", arr[i]);
    }
    return 0;
};